home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
System Booster
/
System Booster.iso
/
Systemmonitors
/
PriMan
/
Source
/
PriMan.h
< prev
next >
Wrap
C/C++ Source or Header
|
1996-09-26
|
13KB
|
368 lines
/*
* Task Priority Manager
* Copyright 1993, 1994 Barry McConnell
* bmccnnll@tcd.ie
*
* PriMan's header file. Contains constant definitions, function protypes,
* and global variables.
*
* Set tab stops to 4 when editing this file.
*
* Every source file #includes this, but we only want one of them to
* actually define the global variables (and the rest to just declare
* them). So I use Eddy Carroll's trick of prefixing all definitions by a
* keyword that gets set to nothing by one file, and "extern" by all the
* rest. Hence, one file should #define MAIN, and it will be that file
* which actually defines the variables.
*/
#ifdef MAIN
#define GLOBAL
#else
#define GLOBAL extern
#endif
#define __USE_SYSBASE /* speeds things up on '020 processors (or greater), as ExecBase is cached */
#include "system.h" /* the system header files */
/*
* The current version number and date go here, and are referenced in
* several places from the other files. This makes it easy to do a global
* update of the version information.
*/
#define VERSION "2.0"
#define DATE "13.11.94"
/*
* Here is another one of Eddy's ideas - a cute macro to walk through a
* linked list. This does all the casting itself!
*/
#define FORLIST(list,p) for ((p) = (void *)(list) -> lh_Head; \
((struct Node *)(p)) -> ln_Succ; \
(p) = (void *)((struct Node *)(p)) -> ln_Succ)
/*
* This saves us bringing in printf() for simple messages.
*/
#define Print(s) Write(Output(), s, strlen(s))
/*
* For the Freeze Task option, we need two extra Exec task states. The
* first one is used when the task was Wait()ing on a signal, and the
* second when it was ready to run when frozen.
*/
#define FROZEN (1<<6)
#define FROZENREADY (1<<5)
/*
* These are defines for the status of the Window Type and Open On cycle
* gadgets.
*/
#define SMARTWINDOW 0
#define SIMPLEWINDOW 1
#define DEFAULTSCREEN 0
#define FRONTSCREEN 1
/*
* Both windows get these IDCMP flags (although technically the Settings
* window doesn't need many of them).
*/
#define WINDOWIDCMP IDCMP_CLOSEWINDOW | IDCMP_REFRESHWINDOW | IDCMP_NEWSIZE | \
IDCMP_SIZEVERIFY | IDCMP_MENUPICK | IDCMP_VANILLAKEY | \
IDCMP_RAWKEY | BUTTONIDCMP | LISTVIEWIDCMP
/*
* Here are some general constants used in the code, some of which are a
* little arbitrary...
*/
#define MaxTasks 256 /* hardcoded maximum number of task we'll process */
#define MaxHotkey 20 /* maximum number of characters in a Commodities hotkey */
#define MaxToolTypes 30 /* maximum allowable number of ToolTypes in PriMan's .info file */
#define MaxStdTools 19 /* number of ToolTypes we reserve for ourselves */
#define MaxToolName 10 /* longest ToolType name ("LISTFONT=" plus NULL at end) */
#define ScrollBarWidth 16 /* width of a ListView scrollbar */
#define ListEarlyClip 6 /* number of extra horizontal pixels ListView needs under 2.x */
#define CloseBoxWidth 19 /* width of a close gadget (so we can neatly indent the Settings window) */
#define CycleWidth 24 /* width of a cycle gadget's imagery */
#define PressDelay 5 /* duration a button gets highlighted for if its keyboard shortcut is used */
#define BreakDelay 25 /* amount of time to wait after sending a Break signal to a task */
/*
* For the non-printable keyboard shortcuts, their values are included
* here. The first three are VANILLAKEY, with the last being RAWKEY.
*/
#define TAB 9
#define RETURN 13
#define ESCAPE 27
#define HELP 95
/*
* Every gadget must have a unique identifier, listed here.
*/
#define LISTGAD 1
#define SLIDERGAD 2
#define BREAKGAD 3
#define KILLGAD 4
#define SETTINGSGAD 6
#define GFONTGAD 7
#define LFONTGAD 8
#define GBOXGAD 9
#define LBOXGAD 10
#define CONFIRMGAD 11
#define ICONIFYGAD 12
#define SAVEGAD 13
#define USEGAD 14
#define CANCELGAD 15
#define COMGAD 16
#define POPUPGAD 17
#define HOTKEYGAD 18
#define PRIORITYGAD 19
#define TOOLPRIGAD 20
#define PAGEGAD 21
#define REFRESHGAD 22
#define OPENGAD 23
/*
* These are the possible errors PriMan can encounter.
*/
#define LOCK_ERROR 1
#define VISINFO_ERROR 2
#define FONT_ERROR 3
#define GADGET_ERROR 4
#define MAIN_ERROR 5
#define TASK_ERROR 6
#define SETTINGS_ERROR 7
#define CX_ERROR 8
#define MENU_ERROR 9
/*
* This isn't really an error; it just allows PriMan to fall out of the
* main loop, and then exit.
*/
#define ALL_OKAY 100
/*
* Here are the defines for the various menu items. They are dependent on
* the position each item appears in the NewMenu structure. The prefixes
* mean the following:
*
* M = menu title
* I = menu item
* S = sub menu item (not used)
*/
#define M_PROJECT 0
#define I_SETTINGS 0
#define I_ABOUT 2
#define I_HELP 3
#define I_HIDE 5
#define I_QUIT 6
#define M_TASK 1
#define I_UPDATE 0
#define I_KILL 2
#define I_SIGNAL 4
#define I_PRIORITY 5
#define I_FROZEN 7
#define I_WIDE 9
/*
* All the functions get declared here. The first bunch are
* from Main.c, Window.c and Event.c:
*/
void main(int, char **);
void HandleToolTypes(char **, BOOL *);
void OpenMainWindow(void);
void OpenSettingsWindow(void);
void CreateList(struct Remember **);
void CreateString(struct Task *, char *);
void HandleMainWindow(ULONG, WORD, WORD, WORD, UWORD, UWORD, struct Gadget *);
void HandleSettingsWindow(ULONG, WORD, WORD, WORD, UWORD, struct Gadget *);
/*
* The rest are from Util.c (alphabetically sorted):
*/
void BusyPointer(void);
void CloseMainWindow(void);
void CloseSettingsWindow(void);
void CloseWindowSafely(struct Window *);
int Compare(char *, char *);
int CompareTasks(char *, char *);
void DrawSettingsBox(void);
void FontString(struct TextAttr *, char *);
BOOL Frozen(struct Task *);
void GetListTop(void);
void GetPos(void);
void Help(void);
void Hide(void);
void Iconify(void);
struct Screen *LockOurScreen(BOOL);
void MenuEllipsis(struct Menu *, BOOL);
void NewPage(WORD);
void NormalPointer(void);
void OffTask(void);
void OnTask(void);
void PressGadget(struct Window *, struct Gadget *);
void Range(WORD *, WORD, WORD);
BOOL RequestFont(struct FontRequester **, struct FontRequester *, char *, WORD *, struct Gadget *, char *, char *, ULONG);
void SetupCommodity(void);
void Show(void);
LONG SimpleRequest(struct EasyStruct *, APTR);
int __regargs sprintf(char *, char *, ...);
WORD Step(WORD, WORD, UWORD);
BOOL ValidTask(struct Task *);
void WideSlider(BOOL);
void WipePort(struct MsgPort *);
/*
* Here is a standard Node type with extra space to store a pointer to the
* original task structure, so we can find it again.
*/
struct ListType
{
struct Node mainNode;
struct Task *mainTask;
};
/*
* Finally, all the global variables go here. A lot of them rely on the
* fact that they get initialised to zero at runtime.
*/
GLOBAL int taskCount, /* number of tasks in ListView */
pos, /* currently-selected task (or -1 if none) */
taskLength, /* maximum length of an entry in ListView */
error; /* something bad happened - abort ASAP */
GLOBAL ULONG guideSignal; /* if set, we need to check for AmigaGuide messages */
GLOBAL LONG top; /* ordinal number of top entry */
GLOBAL UWORD osver; /* Kickstart version */
GLOBAL WORD winLeft, winTop, /* these are the main window's dimensions */
winWidth, winHeight,
minWidth, minHeight, /* minimum space gadgetry will fit into */
iconLeft, iconTop, /* position of AppIcon */
windowTop, /* height of window's title bar */
height, /* height of default screen (Gadget) font */
sysHeight, sysWidth, /* height and width of system default (List) font */
setGadStart, setGadHeight, /* top edge and height of Settings gadget page */
page; /* current page of Settings gadgets (or -1 if none) */
GLOBAL BOOL newPropFont, /* a new Gadget font was chosen */
newMonoFont; /* a new List font was chosen */
GLOBAL char myName[40]; /* pathname used when manipulating the .info file */
GLOBAL void *visInfo; /* VisualInfo structure for GadTools */
GLOBAL CxObj *broker, /* parts making up the Commodity structure */
*filter,
*sender,
*translate;
/*
* These are the strings placed in the Gadget and List font
* boxes. (Sizewise they are no longer than those in the
* font structures, since the ".font" part is stripped off,
* and replaced with the font size.)
*/
GLOBAL char propString[MAXFONTNAME],
monoString[MAXFONTNAME];
/*
* The next few variables are the settings in operation at
* the moment. (The font names are here, but their sizes
* are stored in the TextAttr structures below.)
*/
GLOBAL WORD refresh, /* Window Type */
open, /* Open On */
commodity, /* Install as a Commodity */
popup, /* Popup When Launched */
confirm, /* Confirm Actions */
iconify; /* Iconify When Closed */
GLOBAL char propName[MAXFONTNAME], /* name of Gadget Font */
monoName[MAXFONTNAME], /* name of List Font */
hotkey[MaxHotkey + 1]; /* Commodity hotkey */
GLOBAL BYTE priority; /* Commodity priority */
/*
* These variables are temporary copies of the settings
* above which the user plays around with from the Settings
* window. We don't need temporary copies of the hotkey or
* priority values, since the string and integer gadgets
* serve that purpose. But we do need copies of the two
* font structures - or more precisely, the names and sizes
* embedded within them. We can't rely on the ASL font
* requester to store these, since the user might pick a
* different font and then click Cancel!
*/
GLOBAL WORD tempRefresh,
tempOpen,
tempCommodity,
tempPopup,
tempConfirm,
tempIconify,
tempPropSize,
tempMonoSize;
GLOBAL char tempPropName[MAXFONTNAME],
tempMonoName[MAXFONTNAME];
GLOBAL AMIGAGUIDECONTEXT guideHandle; /* reference to AmigaGuide file */
GLOBAL struct NewAmigaGuide myGuide; /* AmigaGuide structure used when opening file */
GLOBAL struct Library *AmigaGuideBase; /* AmigaGuide library base for online help */
GLOBAL struct Screen *myScreen; /* public screen PriMan is open on */
GLOBAL struct Window *mainWindow, /* PriMan's main window */
*setWindow; /* PriMan's Settings window */
GLOBAL struct Menu *menuStrip; /* main window's menu strip */
GLOBAL struct TextAttr propTA, /* structure used for opening the Gadget Font */
monoTA; /* structure used for opening the List Font */
GLOBAL struct TextFont *propFont, /* pointer to opened Gadget Font */
*monoFont; /* pointer to opened List Font */
GLOBAL struct List taskList; /* contents of ListView */
GLOBAL struct MsgPort *winPort, /* window message port */
*cxPort, /* Commodities message port */
*appPort; /* AppIcon message port */
GLOBAL struct DiskObject *myIcon, /* PriMan's .info file */
*wbIcon; /* AppIcon template (essentially a copy of myIcon) */
GLOBAL struct AppIcon *appIcon; /* AppIcon structure */
GLOBAL struct Image blank; /* for clearing gadget imagery */
GLOBAL struct Remember *memoryKey; /* memory occupied by task list */
GLOBAL struct Node *current; /* entry in ListView currently selected */
GLOBAL struct Task *currentTask; /* structure of task currently selected */
GLOBAL struct FontRequester *propFontReq, /* ASL Gadget font requester */
*monoFontReq; /* ASL List font requester */
GLOBAL struct Gadget *mainGads, /* gadgets in main window */
*setGads[4], /* gadgets in Settings window */
*listGad, /* individual gadget structures */
*sliderGad,
*breakGad,
*killGad,
*setGad,
*pageGad,
*saveGad,
*useGad,
*cancelGad,
*propFontGad,
*propFontButGad,
*monoFontGad,
*monoFontButGad,
*refreshGad,
*confirmGad,
*iconifyGad,
*openGad,
*toolpriGad,
*comGad,
*popupGad,
*hotkeyGad,
*priorityGad;
/*
* The last couple of variables are actually defined in other source files
* (because it's easier to initialise them once there), but used by several
* different files, and hence are always extern here.
*/
extern struct ExecBase *SysBase; /* ExecBase structure, from the includes */
extern struct NewBroker newBroker; /* Commodity broker structure, from main.c */